% computes target frequency, target lines and radius 
% for current block size;
% note Parzen window sizes are hard written here
% part of Mt processing codes
% usage [TLine,TLRad,TLFreq,TBand] =  SetTLine(block)
% latest date 07.11.2001
% 

function[TLine,TLRad,TLFreq,TBand] =  SetTLine(block),

	RadSize = [0.125 0.25 0.5 0.75];   % size of Parzen window
	RdBd    = [2 1 3 3 3];	% rad size for bands
	DeltaFreq = [32.0 1.0 1.0/32.0 1.0/1024.0 1.0/32768.0];
 	MinFreq      = 1.0 / 4097.0;
	MaxFreq      = 8193.0;



%---------Pl do not change the frequency setting !!!!-------------------
TLFreq = [8160	5952	4352	3168	2304	1696	1248	896	672	480	352	256	192	144	108	81	60	44	34	25	20	13	10	8	6	4.5	3.37	2.53	1.87	1.4	1.06	0.78125	0.595238095	0.438596491	0.344827586	0.25	0.187617261	0.140646976	0.105485232	0.079113924	0.058616647	0.043956044	0.033211558	0.024414063	0.018556318	0.013672409	0.010742292	0.0078125	0.005859604	0.004394639	0.003295979	0.002471943	0.001831066	0.001373306	0.001037603	0.000762939	0.000579835	0.000427246	0.000335694	0.000244141];
%---------Pl do not change the frequency setting !!!!-------------------


for Index = 1:length(TLFreq),

    if TLFreq(Index) < 8.0/1024.0,
      TLFreq(Index) =  floor(TLFreq(Index) / DeltaFreq(5) + 0.5)*DeltaFreq(5);
	TBand(Index) = 5;
    elseif TLFreq(Index) < (8.0/32.0),
      TLFreq(Index) =  floor(TLFreq(Index) / DeltaFreq(4) + 0.5)*DeltaFreq(4);
	TBand(Index) = 4;
    elseif TLFreq(Index)   < 8.0 ,
      TLFreq(Index) =  floor(TLFreq(Index) / DeltaFreq(3) + 0.5)*DeltaFreq(3);
	TBand(Index) = 3;
    elseif TLFreq(Index) < 256.0,
      TLFreq(Index) =  floor(TLFreq(Index) / DeltaFreq(2) + 0.5)*DeltaFreq(2);
	TBand(Index) = 2;
	else,
      TLFreq(Index) =  floor(TLFreq(Index) / DeltaFreq(1) + 0.5)*DeltaFreq(1);
	TBand(Index) = 1;
    end;


    if TLFreq(Index) <= MinFreq,
      TLFreq(Index)  = MinFreq;
    elseif TLFreq(Index) >= MaxFreq,
      TLFreq(Index)  = MaxFreq;
    end;


%    -  set targetlines and band                            
%    -  targetlines are set for block size of 1024 points 

    if TLFreq(Index) < 8.0/1024.0,
      TLine(Index) =  floor(TLFreq(Index) / DeltaFreq(5) + 0.5);
    elseif TLFreq(Index) < (8.0/32.0),
      TLine(Index) =  floor(TLFreq(Index) / DeltaFreq(4) + 0.5);
    elseif TLFreq(Index)   < 8.0 ,
      TLine(Index) =  floor(TLFreq(Index) / DeltaFreq(3) + 0.5);
    elseif TLFreq(Index) < 256.0,
      TLine(Index) =  floor(TLFreq(Index) / DeltaFreq(2) + 0.5);
	else,
      TLine(Index) =  floor(TLFreq(Index) / DeltaFreq(1) + 0.5);
    end;


%   -- set correct targetline in respect to block 


	if block == 128,
	TLine(Index) = round((TLine(Index) +1 ) / 8);
	elseif block == 256,
	TLine(Index) = round((TLine(Index) +1) / 4);
	elseif block == 512,
	TLine(Index) = round((TLine(Index)) / 2);
	elseif block == 1024,
	TLine(Index) = TLine(Index);
	elseif block == 2048,
	TLine(Index) = round((TLine(Index) +1) * 2);
	elseif block == 4096,
	TLine(Index) = round((TLine(Index) +1) * 4);
end;



%------  set radius  ---------------------------------------


	TLRad(Index) = floor(TLine(Index) * RadSize(RdBd(TBand(Index))) + 0.5 );

%----- check radius boundaries 

 %   if TLRad(Index) < MinParzenRad,
 %     TLRad(Index) = MinParzenRad;
%    elseif TLRad(Index) > MaxParzenRad,
%      TLRad(Index) = MaxParzenRad;
%    end;

end;


